﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace zielonka.co.uk.extensions.system
{
    //Description:	Shortcut for System.String.Format
    /*
        string greeting = "Hello {0}, my name is {1}, and I own you."

        Console.WriteLine(greeting.With("Adam", "Microsoft"))
    */

    public static partial class StringExtensions
    {
        public static string With(this string format, object arg, params object[] additionalArgs)
        {
            if (additionalArgs == null || additionalArgs.Length == 0)
            {
                return string.Format(format, arg);
            }
            else
            {
                return string.Format(format, new object[] {arg}.Concat(additionalArgs).ToArray());
            }
        }
    }
}
